package com.school.aftersalemanagement.service.impl;

import android.content.Context;
import android.os.Handler;

import com.school.aftersalemanagement.callback.impl.RegisterCallback;
import com.school.aftersalemanagement.callback.impl.UserCallback;
import com.school.aftersalemanagement.global.Apis;
import com.school.aftersalemanagement.service.Service;
import com.school.aftersalemanagement.service.UserService;
import com.zhy.http.okhttp.request.RequestCall;

/**
 * Created by winkyle on 2017/11/8.
 */

public class UserServiceimpl extends Service implements UserService{

    public UserServiceimpl(Context context, Handler handler) {
        super(context, handler);
    }

    @Override
    public void register(String deviceid, String account, String password,String divice_token,int MessageType) {
        map.clear();
        if ("".equals(password)) {
            showShort("请输入密码");
        } else{
            map.put("device_id",deviceid);
            map.put("account",account);
            map.put("password",password);
            map.put("divice_token",divice_token);
            RequestCall requestCall = postRequestCall(Apis.Base + Apis.userlogin,map);
            requestCall.execute(new RegisterCallback(requestCall,handler,MessageType,context,false));
        }
    }


    @Override
    public void validateUser(String deviceId,int MessageType) {
        map.clear();
        map.put("device_id",deviceId);
        RequestCall requestCall = getRequestCall(Apis.Base + Apis.validateUser,map);
        requestCall.execute(new UserCallback(requestCall,handler,MessageType,context,true));
    }
}
